<template>
  <el-popover v-model="cronPopover">
    <cron v-model="scheduleConf" @change="onChangeCron" @close="cronPopover = false"></cron>
    <el-input
      slot="reference"
      @click="cronPopover = true"
      v-model="scheduleConf"
      placeholder="请输入定时策略"
      size="small"
    ></el-input>
  </el-popover>
</template>
<script>
import { cron } from "vue-cron";
export default {
  name: "ScheduleConf",
  props: {
    value: String,
  },
  components: {
    cron,
  },
  data() {
    return {
      scheduleConf: this.data,
      cronPopover: false,
    };
  },
  methods: {
    onChangeCron(v) {
      this.scheduleConf = v;
      this.$emit("input", v);
    },
  },
  watch: {
    value: {
      handler(val) {
        // 初始化
        if (val) {
          this.scheduleConf = val;
        }
      },
      deep: true,
      immediate: true,
    },
  },
};
</script>
